<?php
include "../connect.php";

if (empty($_POST)) {
  $json["errorcode"] = 1;
  $json["msg"] = "请求不到的数据!";
  die(json_encode($json));
}
$movieId = $_POST['movieId'];
$title = $_POST['title'];
$summary = addslashes($_POST['summary']);
$score = $_POST['rating'];
$count = $_POST['ratingCount'];
$scenarist = $_POST['scenarist'];
$image = $_POST['image'];
$runtime = $_POST['runtime'];
$director = $_POST['director'];
$cast = $_POST['cast'];
$year = $_POST['year'];
$type = $_POST['movie_type'];
$playDate = implode(' / ', $_POST['playDate']);
$sql = "insert into movies values ('{$movieId}', '{$title}', '{$summary}', '{$score}', '{$count}', '{$scenarist}', '{$image}', '{$runtime}', '{$director}', '{$cast}', '{$year}', '{$type}', '{$playDate}')";
if ($mysql->query($sql)) {
  $json["errorcode"] = 0;
  $json["msg"] = "添加成功!";
} else {
  $json["errorcode"] = 1;
  $json["msg"] = $mysql->error;
}

echo json_encode($json);
